// logs.js
const app = getApp()

//正式
// 18618113361  账号
// 1234567  密码

// 测试16619916226


Page({
    data: {
        parameter: {
            'navbar': '1',
            'return': '0',
            'title': '海螺号工蜂',
            'color': true,
            'class': false
        },
        username: '',
        password: '',
        sizeW: 0,
        sizeH: 0,
        userInfo: {},
        BannerInfo: {},
        navH: app.globalData.navHeight
    },
    onLoad() {
        this.getCode()
    },
    // 获取UNinID需要的code
    getCode() {
        let that = this;
        wx.login({
            success(res) {
                that.setData({
                    'wxLiteLoginParam.jsCode': res.code
                })
            }
        })
    },
    // 发送给朋友
    onShareAppMessage: function (res) {
        if (res.from === 'button') {
            // 来自页面内转发按钮
        }
        return {
            title: '海螺号工蜂',
            path: 'pages/logs/logs'
        }
    },
    //输入密码
    enterPassword(e) {
        this.setData({
            password: e.detail.value
        })
    },
    // 输入手机号
    enterPhone(e) {
        this.setData({
            username: e.detail.value
        })
    },
    /* 
      登录
    */
    signIn() {
        var data = {
            password: this.data.password,
            username: this.data.username,
            wxLiteSettingsId: 4,
            jsCode: this.data.wxLiteLoginParam.jsCode
        }
        app.basePost(app.U({
            m: 'factory',
            c: 'sysuser',
            a: 'login'
        }), data, res => {
            if (res.code == 200) {
                wx.setStorage({
                    key: 'userInfo', //key名
                    data: res.data //值
                })
                wx.setStorage({
                    key: 'user', //key名
                    data: res //值
                })
                wx.setStorage({
                    key: 'token', //key名
                    data: res.data.token //值
                })
                wx.setStorage({
                    key: 'userpass', //key名
                    data: data //值
                })
                wx.switchTab({
                    url: "/pages/home/index"
                })
            }
        });
    },
    /* 
      忘记密码
    */
    forgetPassword() {
        wx.navigateTo({
            url: "/pages/logs/forgetPassword/index"
        })
    }

})